﻿namespace Borg.AttributeAnalyze.Result
{
    public class InvalidParameterValue : ResultBase
    {
        private readonly ParamDefinition _parameterDefinition;
        private readonly ParamValue _parameterValue;
        private readonly PlugTypeInfo _plug;

        public InvalidParameterValue(PlugTypeInfo plug, ParamDefinition parameterDefinition, ParamValue parameterValue)
            : base(plug.Assembly, Component.Plug, ResultType.InvalidParameterValue, plug, plug.ExtensionTypeInfo)
        {
            _plug = plug;
            _parameterValue = parameterValue;
            _parameterDefinition = parameterDefinition;
        }

        public override string ToMsBuildMessageString()
        {
            return string.Format(
                "invalid value for parameter specified\n{0}slot name: {1}\n{0}class:" +
                " {2}\n{0}parameter name: {3}\n{0}parameter value: {4}\n{0}parameter type: {5}",
                new [] { GetWhiteSpace(2), Name, TypeName, _parameterValue.Name,
                    _parameterValue.Value, _parameterDefinition.Type.Name });
        }

        public override MessageType MessageType
        {
            get { return MessageType.Error; }
        }
    }
}

